﻿<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title>壹果企画(北京)科技有限公司-运营管理系统</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<!-- STYLESHEETS --><!--[if lt IE 9]><script src="js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
	<link rel="stylesheet" type="text/css" href="../css/cloud-admin.css" >
	
	<link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet">

	<!-- ANIMATE -->
	<link rel="stylesheet" type="text/css" href="../css/animatecss/animate.min.css" />
	
</head>
<body class="login">	
	<!-- PAGE -->
	<section id="page">
		
			<!-- LOGIN -->
			<section id="login" class="visible">
				<div class="container">
					<div class="row">
						<div class="col-md-4 col-md-offset-4">
							<div class="login-box-plain">
							<div style="margin-left:50px"><img src="../img/logo/logo2.jpg"></div>
								
								<div class="divide-40"></div>
								<form role="form">
								  <div class="form-group">									
									<i class="fa fa-user" style="margin-top:15px"></i>
									<input type="text" class="form-control" name="username" style="height: 40px" >
									<div class="text-danger" style="display:none"><span>请输入用户名</span></div>
								  </div>
								  <div class="form-group"> 									
									<i class="fa fa-lock"></i>
									<input type="password" class="form-control" name="password" >
									<div class="text-danger" style="display:none"><span>请输入密码</span></div>
								  </div>								  
								  <div class="form-group">									
									<button type="submit" class="btn btn-danger" disabled="">登录</button>
								  </div>
								</form>
								
								
							</div>
						</div>
					</div>
				</div>
			</section>
			<!--/LOGIN -->
		
			
	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="../js/jquery/jquery-2.0.3.min.js"></script>
	<!-- JQUERY UI-->
	<script src="../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
	<!-- BOOTSTRAP -->
	<script src="../bootstrap-dist/js/bootstrap.min.js"></script>
	<!-- UNIFORM -->
	<script type="text/javascript" src="../js/uniform/jquery.uniform.min.js"></script>
	<!-- CUSTOM SCRIPT -->
	<script src="../js/script.js"></script>
	
	<script type="text/javascript">
		var Login=function(){
		 var submit=function(e){	     
		     e.preventDefault();
		     var username=$("[name=username]").val();
		     var password=$("[name=password]").val();
		     
		     if(username=="")
		     {
		        $("[name=username]").next("div").show();
		        return false;
		     }
		     if(password=="")
		     {
		        $("[name=password").next("div").show();
		        return false;
		     }
		     if($("[name=password").next("div").attr("status")=="error"){
		        return false;
		     }
		     $("button").attr("disable",true);
		          $.ajax({
						type: "post",
						url: App.getContextPath() + "admin/login.do",
						data:{username:username,password:password},
						async: true,
						success: function(result) {
						
							if(result.key=="LOGIN_SUCCESS"){
							  location.href="index.html";
							}else{
							   $("[name=password]").next("div").html(result.val).show();
							   $("[name=password").next("div").attr("status","error");
							    $("button").removeAttr("disabled");
							}
						}
					});
		 
		 }
		var validatePassword = function(){
	        $(this).parents(".form-group").removeClass("has-error").addClass("has-success"); 
	        $(this).next("div").hide();
	        if($("[name=username]").val()!=""){
	         $("button").removeAttr("disabled");
	         $("button").unbind('click').click(submit);
	        }
		}
		  return {		  
		     init:function(){
		     //用户名离开
		     $("[name=username]").blur(function(){
		         $(this).next("div").hide();	         
		        if($(this).val()=="")
		        {
		        	$(this).next("div").show();
		        	$(this).parents(".form-group").removeClass("has-success").addClass("has-error");
		        	$(this).focus();
					return false;		        
		        }else{
		         $(this).parents(".form-group").removeClass("has-error").addClass("has-success"); 
		        }
		     });
		      //用户名离开
		     $("[name=password]").blur(function(){
		        $(this).next("div").hide();	         
		        if($(this).val()=="")
		        {
		        	$(this).next("div").show();
		        	$(this).parents(".form-group").removeClass("has-success").addClass("has-error");
		        	$(this).focus();
		        	$("button").attr("disable",true);
					return false;		        
		        }else{
		         $("[name=password").next("div").attr("status","");
		         $(this).parents(".form-group").removeClass("has-error").addClass("has-success"); 
		        }
		     });
		     $("[name=password]").keypress(validatePassword);
		     $("[name=password]").change(validatePassword);
		     if($("[name=username]").val()!=""){
		         $("button").removeAttr("disabled");
		         $("button").unbind('click').click(submit);
		        }
		     
		     }
		  
		  }
		
		
		}();
		$(function(){
		  Login.init();
		});
	</script>
	<!-- /JAVASCRIPTS -->
</body>
</html>